/*
 * @Author: Otway
 * @Date: 2019-01-09 11:16:08
 * @LastEditors: Otway
 * @LastEditTime: 2019-08-30 18:50:09
 * @copyright: h-visions
 */
import React, { PureComponent } from 'react';
import {
    Row,
    Col,
    Form,
    Radio,
} from 'antd';
const FormItem = Form.Item;
const formItemLayout = {
    // 抽屉里面Form。二列的布局比例
    labelCol: {
        span: 6
    },
    wrapperCol: {
        span: 18
    }
};

class AddFrom extends PureComponent {

    onChange = (a) => {
        const { update } = this.props
        update(a)
    }
    render() {
        const {
            formData,
            form: { getFieldDecorator },
        } = this.props;
        const radioStyle = {
            height: '30px',
            lineHeight: '30px',
        };
        // console.log('这是', formData);  
        return (
            <Form >
                <Row>
                    <Col span={24}>
                        <FormItem {...formItemLayout} >
                            {getFieldDecorator('version', {
                                initialValue: formData.ecnCode || '',
                                rules: [
                                    {
                                        required: true,
                                        message: '请选择版本'
                                    }
                                ]
                            })(<Radio.Group>
                                {
                                    formData ? formData.map((value, index) => {
                                        return <Radio style={radioStyle} value={value.version} key={value.id} onChange={() =>
                                            this.onChange({ version: value.version, id: value.id, batchNo: value.batchNo, isGrey: value.isGrey })
                                        }>
                                            批号：<span>{value.batchNo}</span> — 版本：<span style={{ color: '#1890ff', marginRight: '20px' }}>{value.version}</span>创建时间：<span>{value.createTime}</span>
                                        </Radio>
                                    }) : null
                                }
                            </Radio.Group>)}
                        </FormItem>
                    </Col>
                </Row>
            </Form>
        );
    }
}

export default Form.create()(AddFrom);